# Contributor: k0r10n <k0r10n.dev@gmail.com>
# Contributor: Jose-Luis Rivas <ghostbar@riseup.net>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=libzip
pkgver=1.10.1
pkgrel=0
pkgdesc="C library for manipulating zip archives"
url="https://libzip.org/"
arch="all"
license="BSD-3-Clause"
depends_dev="$pkgname-tools=$pkgver-r$pkgrel bzip2-dev xz-dev zlib-dev zstd-dev"
makedepends="$depends_dev cmake openssl-dev>3 perl samurai"
checkdepends="nihtest"
subpackages="$pkgname-dev $pkgname-doc $pkgname-tools"
source="https://libzip.org/download/libzip-$pkgver.tar.xz"

# secfixes:
#   1.3.0-r0:
#     - CVE-2017-14107

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_EXAMPLES=OFF \
		-DENABLE_BZIP2=ON \
		-DENABLE_LZMA=ON \
		-DENABLE_OPENSSL=ON \
		-DENABLE_ZSTD=ON \
		-DCMAKE_BUILD_TYPE=MinSizeRel
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

tools() {
	pkgdesc="$pkgname cmp and merge tools"

	amove usr/bin
}

sha512sums="
d24670ca3fa5def0345d6c531045683f11a124af7975dd724eae3bf3128a62fb8185a3d4df029c7c8232c7584e5ac55d18c431dc53b91e992fbbc8d119442930  libzip-1.10.1.tar.xz
"
